local skel = fk.CreateSkill {
  name = "efengqi__haoshi",
}

Fk:loadTranslationTable{
  ["efengqi__haoshi"] = "好施",
  [":efengqi__haoshi"] = "出牌阶段限一次，你可以摸随机0~5张牌（场上已有的手牌数不会被随机到），再将一半手牌（向上取整）交给一名其他角色。",

  ["#efengqi__haoshi"] = "好施：摸随机0-5张牌（不被随机到已有的手牌数），再将一半手牌交给一名其他角色",
  ["#efengqi__haoshi-give"] = "好施：将 %arg 张手牌交给一名其他角色",

  ["$efengqi__haoshi1"] = "拿去拿去，莫跟哥哥客气！",
  ["$efengqi__haoshi2"] = "来来来，见面分一半。",
}

skel:addEffect("active", {
  anim_type = "drawcard",
  card_num = 0,
  target_num = 0,
  prompt = "#efengqi__haoshi",
  card_filter = Util.FalseFunc,
  times = function (self, player)
    return 1 - player:usedSkillTimes(skel.name, Player.HistoryPhase)
  end,
  can_use = function(self, player)
    return player:usedSkillTimes(skel.name, Player.HistoryPhase) == 0
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local nums = {0,1,2,3,4,5}
    for _, p in ipairs(room.alive_players) do
      table.removeOne(nums, p:getHandcardNum())
    end
    if #nums == 0 then nums = {0} end
    local num = table.random(nums)
    player:drawCards(num, skel.name)
    if player.dead or player:isKongcheng() then return end
    num = (player:getHandcardNum() + 1) // 2
    local targets = room:getOtherPlayers(player, false)
    if #targets == 0 then return end
    local tos, ids = room:askToChooseCardsAndPlayers(player, {
      min_card_num = num, max_card_num = num, pattern = ".|.|.|hand", min_num = 1, max_num = 1,
      targets = targets, prompt = "#efengqi__haoshi-give:::"..num, cancelable = false, skill_name = skel.name
    })
    room:obtainCard(tos[1], ids, false, fk.ReasonGive, player, skel.name)
  end,
})



return skel
